home *** CD-ROM | disk | FTP | other *** search
/ Wayzata's Best of Shareware PC/Windows 2 / Wayzata's Best of Shareware 2.0 (Windows) (Wayzata Technology)(7112)(1994).bin / pc / dos / programg / decgif3 / rescale.asm < prev    next >
Assembly Source File  |  1992-07-17  |  3KB  |  62 lines

  1. ;*******************************************************************************
  2. ;* Assembly Subroutines For DECGIF3.BAS 
  3. ;* By Rich Geldreich 1992
  4. ;* Assembled with TASM v2.00
  5. ;*
  6. ;* Routine for rescaling an integer array containing a scan line.
  7. ;* Simple pixel slashing- no bells or whistles.
  8. ;* 
  9. ;*
  10. .286
  11. Ideal
  12. Model Small
  13. Public Rescale
  14. CodeSeg
  15. Even
  16. Proc    Rescale ;A() B() NumPoints NewScale
  17.                 ;12  10      8        6
  18.         Push    bp                              ;Get stack frame. 
  19.         Mov     bp, sp                          
  20.         Push    es ds si di                     ;Save important regs.
  21.                 
  22.         Mov     bx, [ss:bp+10]                  ;Get location of destination
  23.         Mov     di, [ds:bx+0Ah]                 ;array.
  24.         Mov     es, [ds:bx+02h]
  25.         
  26.         Mov     bx, [ss:bp+12]                  ;Get location of source array.
  27.         Mov     si, [ds:bx+0Ah]
  28.         Mov     ds, [ds:bx+02h]
  29.  
  30.         Mov     dx, [ss:bp+06]                  ;Get new scale.
  31.         Mov     bp, [ss:bp+08]                  ;Get number of pixels to sling.
  32.         Shl     bp, 1                           ;* 2 for words.
  33.         Add     bp, si                          ;BP has end address now.
  34.         
  35.         Mov     bl, dh                          ;bx have high step.
  36.         Xor     dh, dh                          ;dl has low step
  37.         Mov     bh, dh                          ;Clear bh too.
  38.         
  39.         Even                                    ;Faster to jump to an even address.
  40. @@10:
  41.         Mov     al, [ds:si]                     ;Get a pixel.
  42.         Stosb                                   ;Sling it.
  43.         Inc     di
  44.         
  45.         Add     dh, dl                          ;Add up remainder.
  46.         Mov     cx, si                          ;For checking is si changes.
  47.         Adc     si, bx                          ;Add carry and high step to source.
  48.         Cmp     si, cx                          ;Did it change?
  49.         Je      @@20                            
  50.         Sub     cx, si                          ;See how much.
  51.         Neg     cx                              ;It's gotta be negative.
  52.         Add     si, cx                          ;Add it for words.
  53. @@20:        
  54.         Cmp     si, bp                          ;All pixels slung?
  55.         Jnae    @@10                            ;Nope.
  56.  
  57.         Pop     di si ds es bp                  ;Pop regs and return.
  58.         Retf    8
  59. Endp    Rescale                                 
  60. End
  61.         
  62.